/**
 * Created by way on 16/6/11.
 */
var path = require('path');
var webpack = require('webpack');

// 插件配置
var getPlugins = function(env) {
  plugins =  [
    new webpack.optimize.UglifyJsPlugin({
      output: {
        comments: false,
      },
      compress: {
        warnings: false
      },
      sourceMap: false,
      mangle: {
        except: ['$', 'jQuery']
      }
    })
  ];

  /*  
  var defaultPlugins = [
        // 这个不仅是别名，还可以在遇到别名的时候自动引入模块
        new webpack.ProvidePlugin({
            '$': 'jquery.js',
            'jquery': 'jquery.js',
            'jQuery': 'jquery.js',
        }),
        // 抽离公共模块
        new webpack.optimize.CommonsChunkPlugin('common', 'common.js'),        
        new ExtractTextPlugin(
            path.join('../../stylesheets', project, '/[name].css'), {
                allChunks: true
            }
        )
    ];

    if (env == 'production') {
        // 线上模式的配置，去除依赖中重复的插件/压缩js/排除报错的插件
        plugins = _.union(defaultPlugins, [
            new webpack.optimize.DedupePlugin(),
            new webpack.optimize.UglifyJsPlugin({
                sourceMap: false,
                mangle: {
                    except: ['$', 'jQuery']
                }
            }),
            new webpack.NoErrorsPlugin()
        ]);
    } else {
        plugins = _.union(defaultPlugins, []);
    }
*/
    return plugins;
};

module.exports = {
  //entry: {index:'./src/ogcpc/index.js'}, // gulp 输入
  entry: {}, // gulp 输入
	/*
  output: {
    path: path.resolve(__dirname, 'dist/hello/'), // string
    filename: '[name].js'
  },
	*/
  output: {}, // gulp 输入
  resolve: {
    // options for resolving module requests
    // (does not apply to resolving to loaders)
    modules: [
      'node_modules',
      path.resolve(__dirname, 'src')
    ],
    // directories where to look for modules
    extensions: ['.js', '.ts']
    // extensions that are used
  },
  watch: false,
  profile: true,
  cache: true,
  module: {
    rules: [
      { test: /\.(ts|js)$/, loader: 'awesome-typescript-loader', 
        include: [path.resolve(__dirname, 'src')],
        exclude: [path.resolve(__dirname, 'node_modules')]
      }
    ]
  },
  externals: {
    // Zepto: 'Zepto',
    EditTable: 'EditTable'
  },
  // plugins: getPlugins('production')
};
